#!/usr/bin/env python
"""
环境变量设置工具，用于smoke测试
确保在运行测试前设置必要的环境变量
"""
import os
import sys
from typing import Dict

def setup_test_environment():
    """设置测试环境变量"""
    # 基本环境变量
    env_vars = {
        "PROJECT_NAME": "WeChat Assistant",
        "DATABASE_URL": "sqlite:///./wechat_assistant_smoke_test.db",
        "WECHAT_DATA_DIR": "./wechat_data",
        "LOG_LEVEL": "INFO",
        "LOG_FILE": "./logs/smoke_test.log",
    }
    
    # 设置环境变量
    for key, value in env_vars.items():
        os.environ[key] = value
        
    print(f"已设置 {len(env_vars)} 个环境变量用于测试")
    return env_vars

def get_env_status() -> Dict[str, str]:
    """获取当前环境变量状态"""
    env_keys = [
        "PROJECT_NAME", 
        "DATABASE_URL", 
        "WECHAT_DATA_DIR",
        "LOG_LEVEL",
        "LOG_FILE"
    ]
    
    result = {}
    for key in env_keys:
        result[key] = os.environ.get(key, "未设置")
        
    return result

if __name__ == "__main__":
    # 直接运行此脚本时，打印环境变量状态
    setup_test_environment()
    status = get_env_status()
    
    print("\n当前环境变量状态:")
    for key, value in status.items():
        print(f"{key}: {value}") 